package com.hqyj.pojo;



import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Order {
    private int orderid;
    private int userid;
    private int ticketid;
    private Date ordertime;
    private int num;
    public double sumprice;
    private List<Ticket> tickets;
    private List<Payment> payments;

    public void setOrdertime(String ordertime) throws ParseException {
        SimpleDateFormat inputFormat = null;
        if(ordertime.contains("T")){
            inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        }else{
            inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        }
        this.ordertime = inputFormat.parse(ordertime);
    }


}
